const { DataTypes } = require("sequelize");
const sequelize = require("../db/index.js");
const Student = sequelize.define(
  "student",
  {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "主键",
      field: "id",
    },
    name: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "用户名",
      field: "name",
    },
    class: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "班级",
      field: "class",
    },
    birthday: {
      type: DataTypes.DATEONLY,
      allowNull: true,
      comment: "生日",
      field: "birthday",
    },
    sex: {
      type: DataTypes.STRING(20),
      allowNull: true,
      comment: "性别",
      field: "sex",
    },
    avatar: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: "头像",
      field: "avatar",
    },
    loginId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "登录账号",
      field: "loginId",
    },
    password: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "密码",
      defaultValue: "123456",
      field: "password",
    },
  },

  {
    sequelize,
    tableName: "student",
    timestamps: true,
    paranoid: true,
    createdAt: "createTime",
    updatedAt: "updateTime",
    deletedAt: "deleteTime",
  }
);

module.exports = Student;
